package com.ksm.zyz.controller;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ksm.zyz.common.base.BaseController;
import com.ksm.zyz.sys.entity.BaseGoodsInfo;
import com.ksm.zyz.sys.entity.BaseGoodsStock;
import com.ksm.zyz.sys.entity.BaseGoodsUnit;
import com.ksm.zyz.sys.entity.BaseSupplierInfo;
import com.ksm.zyz.sys.entity.BsData;
import com.ksm.zyz.sys.entity.SysCompanyInfo;
import com.ksm.zyz.sys.entity.SysMyuser;
import com.ksm.zyz.sys.entity.xinXibiao;
import com.ksm.zyz.sys.serverentity.Tongbu;
import com.ksm.zyz.sys.serverentity.sBaseChargeInfo;
import com.ksm.zyz.sys.serverentity.sBaseGoodsInfo;
import com.ksm.zyz.sys.serverentity.sBaseGoodsStock;
import com.ksm.zyz.sys.serverentity.sBaseGoodsUnit;
import com.ksm.zyz.sys.serverentity.sBaseSupplierInfo;
import com.ksm.zyz.sys.serverentity.sSysCompanyInfo;
import com.ksm.zyz.sys.serverentity.sSysMyuser;
import com.ksm.zyz.sys.serverentity.sXinXiBiao;
import com.ksm.zyz.sys.serverservice.sBaseChargeInfoService;
import com.ksm.zyz.sys.serverservice.sBaseCustomerInfoService;
import com.ksm.zyz.sys.serverservice.sBaseGoodsInfoService;
import com.ksm.zyz.sys.serverservice.sBaseGoodsStockService;
import com.ksm.zyz.sys.serverservice.sBaseGoodsUnitService;
import com.ksm.zyz.sys.serverservice.sBaseMemberInfoService;
import com.ksm.zyz.sys.serverservice.sBaseMemberLogService;
import com.ksm.zyz.sys.serverservice.sBaseScalesInfoService;
import com.ksm.zyz.sys.serverservice.sBaseShopInfoService;
import com.ksm.zyz.sys.serverservice.sBaseSpecialPriceLogService;
import com.ksm.zyz.sys.serverservice.sBaseSpecialPriceService;
import com.ksm.zyz.sys.serverservice.sBaseSpecialThemeService;
import com.ksm.zyz.sys.serverservice.sBaseSpecialThemegoodsService;
import com.ksm.zyz.sys.serverservice.sBaseSupplierInfoService;
import com.ksm.zyz.sys.serverservice.sBaseSupplierPaytypeService;
import com.ksm.zyz.sys.serverservice.sBaseTypeInfoService;
import com.ksm.zyz.sys.serverservice.sBaseValuecardInfoService;
import com.ksm.zyz.sys.serverservice.sBaseValuecardLogService;
import com.ksm.zyz.sys.serverservice.sBaseVillageService;
import com.ksm.zyz.sys.serverservice.sBaseWarehouseInfoService;
import com.ksm.zyz.sys.serverservice.sBaseWebVillageService;
import com.ksm.zyz.sys.serverservice.sSysCompanyInfoService;
import com.ksm.zyz.sys.serverservice.sSysMyuserService;
import com.ksm.zyz.sys.serverservice.sXinXiBiaoService;
import com.ksm.zyz.sys.service.SysMyuserService;
import com.ksm.zyz.sys.service.XinXiBiaoService;
import com.ksm.zyz.sys.service.baseChargeInfoService;
import com.ksm.zyz.sys.service.baseCustomerInfoService;
import com.ksm.zyz.sys.service.baseGoodsInfoService;
import com.ksm.zyz.sys.service.baseGoodsStockService;
import com.ksm.zyz.sys.service.baseGoodsUnitService;
import com.ksm.zyz.sys.service.baseMemberInfoService;
import com.ksm.zyz.sys.service.baseMemberLogService;
import com.ksm.zyz.sys.service.baseScalesInfoService;
import com.ksm.zyz.sys.service.baseShopInfoService;
import com.ksm.zyz.sys.service.baseSpecialPriceLogService;
import com.ksm.zyz.sys.service.baseSpecialPriceService;
import com.ksm.zyz.sys.service.baseSpecialThemeService;
import com.ksm.zyz.sys.service.baseSpecialThemegoodsService;
import com.ksm.zyz.sys.service.baseSupplierInfoService;
import com.ksm.zyz.sys.service.baseSupplierPaytypeService;
import com.ksm.zyz.sys.service.baseTypeInfoService;
import com.ksm.zyz.sys.service.baseValuecardInfoService;
import com.ksm.zyz.sys.service.baseValuecardLogService;
import com.ksm.zyz.sys.service.baseVillageService;
import com.ksm.zyz.sys.service.baseWarehouseInfoService;
import com.ksm.zyz.sys.service.baseWebVillageService;
import com.ksm.zyz.sys.service.sysCompanyInfoService;

/**
 * @author liuhao
 *
 */
@Controller
@RequestMapping("tongBu")
public class tongBuController extends BaseController<Tongbu> {

	@Autowired
	private sBaseChargeInfoService sBaseChargeInfoService;
	@Autowired
	private baseChargeInfoService BaseChargeInfoService;
	@Autowired
	private sBaseCustomerInfoService sBaseCustomerInfoService;
	@Autowired
	private baseCustomerInfoService BaseCustomerInfoService;
	@Autowired
	private sBaseGoodsInfoService sBaseGoodsInfoService;
	@Autowired
	private baseGoodsInfoService BaseGoodsInfoService;
	@Autowired
	private sBaseGoodsStockService sBaseGoodsStockService;
	@Autowired
	private baseGoodsStockService BaseGoodsStockService;
	@Autowired
	private sBaseGoodsUnitService sBaseGoodsUnitService;
	@Autowired
	private baseGoodsUnitService BaseGoodsUnitService;
	@Autowired
	private sBaseMemberInfoService sBaseMemberInfoService;
	@Autowired
	private baseMemberInfoService BaseMemberInfoService;
	@Autowired
	private sBaseMemberLogService sBaseMemberLogService;
	@Autowired
	private baseMemberLogService BaseMemberLogService;
	@Autowired
	private sBaseScalesInfoService sBaseScalesInfoService;
	@Autowired
	private baseScalesInfoService BaseScalesInfoService;
	@Autowired
	private sBaseShopInfoService sBaseShopInfoService;
	@Autowired
	private baseShopInfoService BaseShopInfoService;
	@Autowired
	private sBaseSpecialPriceLogService sBaseSpecialPriceLogService; //20170325
	@Autowired
	private baseSpecialPriceLogService BaseSpecialPriceLogService;
	@Autowired
	private sBaseSpecialPriceService sBaseSpecialPriceService;
	@Autowired
	private baseSpecialPriceService BaseSpecialPriceService;
	@Autowired
	private sBaseSpecialThemegoodsService sBaseSpecialThemegoodsService;
	@Autowired
	private baseSpecialThemegoodsService BaseSpecialThemegoodsService;
	@Autowired
	private sBaseSpecialThemeService sBaseSpecialThemeService;
	@Autowired
	private baseSpecialThemeService BaseSpecialThemeService;
	@Autowired
	private sBaseSupplierPaytypeService sBaseSupplierPaytypeService;
	@Autowired
	private baseSupplierPaytypeService BaseSupplierPaytypeService;
	@Autowired
	private sBaseTypeInfoService sBaseTypeInfoService;
	@Autowired
	private baseTypeInfoService BaseTypeInfoService;
	@Autowired
	private sBaseValuecardInfoService sBaseValuecardInfoService;
	@Autowired
	private baseValuecardInfoService BaseValuecardInfoService;
	@Autowired
	private sBaseValuecardLogService sBaseValuecardLogService;
	@Autowired
	private baseValuecardLogService BaseValuecardLogService;
	@Autowired
	private sBaseVillageService sBaseVillageService;
	@Autowired
	private baseVillageService BaseVillageService;
	@Autowired
	private sBaseWarehouseInfoService sBaseWarehouseInfoService;
	@Autowired
	private baseWarehouseInfoService BaseWarehouseInfoService;
	@Autowired
	private sBaseWebVillageService sBaseWebVillageService;
	@Autowired
	private baseWebVillageService BaseWebVillageService;
	@Autowired
	private sBaseSupplierInfoService sBaseSupplierInfoService;
	@Autowired
	private baseSupplierInfoService BaseSupplierInfoService;
	@Autowired
	private sSysCompanyInfoService sSysCompanyInfoService;
	@Autowired
	private sysCompanyInfoService SysCompanyInfoService;	
	@Autowired
	private sXinXiBiaoService sXinXiBiaoService;
	@Autowired
	private XinXiBiaoService XinXiBiaoService;
	@Autowired
	private sSysMyuserService sSysMyuserService;
	@Autowired
	private SysMyuserService SysMyuserService;
	
	
	   @RequestMapping(value ="tongbu")
	   @ResponseBody
		public String tongbu(int ming){
		   
		   BsData bsdata=new BsData();
		   int begin=0;
           // 信息表的超市信息的同步
		  xinXibiao XinXiBiao=sXinXiBiaoService.selectXinxi();
				   				   
			  try
			   {
				  XinXiBiaoService.insertSelective(XinXiBiao);					   
			   }
			   catch(Exception e){
				   System.out.println(XinXiBiao.getId()+"@@@@@"); 
			   }
			   
			  int sSysMyuserscount=(int)sSysMyuserService.selectAllCount();
			   sSysMyuser sSysMyuser =new sSysMyuser();
			   bsdata.setBegin(begin);
			   bsdata.setLimit(sSysMyuserscount);
			   sSysMyuser.setBsData(bsdata);
			   List<SysMyuser> SysMyuserlist=sSysMyuserService.selectAllInfo(sSysMyuser);
			   for(int j=begin;j<SysMyuserlist.size();j++)
			   {
				   SysMyuser info=SysMyuserlist.get(j);
				
				   info.setSmId(ming);			   				   
				  try
				   {
					  SysMyuserService.insertSelective(info);					   
				   }
				   catch(Exception e){
					   System.out.println(info.getIsid()+"@@@@@"); 
				   }
				   
			   }

			   int sSysCompanyInfocount=(int)sSysCompanyInfoService.selectAllCount();


			   sSysCompanyInfo sSysCompanyInfoInfo =new sSysCompanyInfo();
			   bsdata.setBegin(begin);
			   bsdata.setLimit(sSysCompanyInfocount);
			   sSysCompanyInfoInfo.setBsData(bsdata);
			   List<SysCompanyInfo> SysCompanyInfolist=sSysCompanyInfoService.selectAllInfo(sSysCompanyInfoInfo);
			   for(int j=begin;j<SysCompanyInfolist.size();j++)
			   {
				   SysCompanyInfo info=SysCompanyInfolist.get(j);
				   System.out.println(SysCompanyInfolist.get(j).getNativename());
				   info.setSmId(ming);			   				   
				  try
				   {
					  SysCompanyInfoService.insertSelective(info);					   
				   }
				   catch(Exception e){
					   System.out.println(info.getId()+"@@@@@");
				   }
				   
			   }
			   
			   int BaseSupplierInfocount=(int)sBaseSupplierInfoService.selectAllCount();

			   sBaseSupplierInfo sBaseSupplierInfo =new sBaseSupplierInfo();
			   bsdata.setBegin(begin);
			   bsdata.setLimit(BaseSupplierInfocount);
			   sBaseSupplierInfo.setBsData(bsdata);
			   List<BaseSupplierInfo> BaseSupplierInfolist=sBaseSupplierInfoService.selectAllInfo(sBaseSupplierInfo);
			   for(int j=0;j<BaseSupplierInfolist.size();j++)
			   {
				   BaseSupplierInfo info=BaseSupplierInfolist.get(j);
				   System.out.println(BaseSupplierInfolist.get(j).getSupplierName());
				   info.setSmId(ming);			   				   
				  try
				   {
					  BaseSupplierInfoService.insertSelective(info);					   
				   }
				   catch(Exception e){
					   System.out.println(info.getId()+"@@@@@");
				   }
				   
			   }  
			  
		   int BaseGoodsInfoscount=(int)sBaseGoodsInfoService.selectAllCount();
		   sBaseGoodsInfo sBaseGoodsInfo =new sBaseGoodsInfo();
		   bsdata.setBegin(begin);
		   bsdata.setLimit(BaseGoodsInfoscount);
		   sBaseGoodsInfo.setBsData(bsdata);
		   List<BaseGoodsInfo> BaseGoodsInfolist=sBaseGoodsInfoService.selectAllInfo(sBaseGoodsInfo);
		   for(int j=begin;j<BaseGoodsInfolist.size();j++)
		   {
			   BaseGoodsInfo info=BaseGoodsInfolist.get(j);
			   System.out.println(BaseGoodsInfolist.get(j).getGoodsName());
			   info.setSmId(ming);			   				   
			  try
			   {
				  BaseGoodsInfoService.insertSelective(info);					   
			   }
			   catch(Exception e){
				   System.out.println(info.getId()+"@@@@@"); 
			   }
			   
		   }

				   
				   
				   int BaseGoodsStockscount=(int)sBaseGoodsStockService.selectAllCount();
					   sBaseGoodsStock sBaseGoodsStock =new sBaseGoodsStock();
					   bsdata.setBegin(begin);
					   bsdata.setLimit(BaseGoodsStockscount);
					   sBaseGoodsStock.setBsData(bsdata);
					   List<BaseGoodsStock> BaseGoodsStocklist=sBaseGoodsStockService.selectAllInfo(sBaseGoodsStock);
					   for(int j=0;j<BaseGoodsStocklist.size();j++)
					   {
						   BaseGoodsStock info=BaseGoodsStocklist.get(j);
						   System.out.println(BaseGoodsStocklist.get(j).getStock());
						   info.setSmId(ming);			   				   
						  try
						   {
							  BaseGoodsStockService.insertSelective(info);					   
						   }
						   catch(Exception e){
							   System.out.println(info.getId()+"@@@@@");
						   }
						   
					   }
					   
					   int BaseGoodsUnitscount=(int)sBaseGoodsUnitService.selectAllCount();
						   sBaseGoodsUnit sBaseGoodsUnitInfo =new sBaseGoodsUnit();
						   bsdata.setBegin(begin);
						   bsdata.setLimit(BaseGoodsUnitscount);
						   sBaseGoodsUnitInfo.setBsData(bsdata);
						   List<BaseGoodsUnit> BaseGoodsUnitlist=sBaseGoodsUnitService.selectAllInfo(sBaseGoodsUnitInfo);
						   for(int j=0;j<BaseGoodsUnitlist.size();j++)
						   {
							   BaseGoodsUnit info=BaseGoodsUnitlist.get(j);
							   System.out.println(BaseGoodsUnitlist.get(j).getUnitName());
							   info.setSmId(ming);			   				   
							  try
							   {
								  BaseGoodsUnitService.insertSelective(info);					   
							   }
							   catch(Exception e){
								   System.out.println(info.getId()+"@@@@@");
							   }
							   
						   }
						   
						   
						     
					   
							   /* int scount=(int)sBaseChargeInfoService.selectAllCount();
							   int begin=0;
							   sBaseChargeInfo sInfo =new sBaseChargeInfo();
							   BsData bsdata=new BsData();
							   bsdata.setBegin(begin);

								   bsdata.setLimit(scount);
								   sInfo.setBsData(bsdata);
								   List<BaseChargeInfo> list=sBaseChargeInfoService.selectAllInfo(sInfo);
								   for(int j=0;j<list.size();j++)
								   {
									   BaseChargeInfo info=list.get(j);
									   System.out.println(list.get(j).getChargeName());
									   info.setSmId(ming);			   				   
									  try
									   {
										  BaseChargeInfoService.insertSelective(info);					   
									   }
									   catch(Exception e){
										   System.out.println(info.getId()+"@@@@@");
										   extData.setTotalCount(j); 
									   }
									   
								   }
								   int BaseCustomerInfoscount=(int)sBaseCustomerInfoService.selectAllCount();

								   System.out.println(BaseCustomerInfoscount+"总数据量");
									   sBaseCustomerInfo sBaseCustomerInfo =new sBaseCustomerInfo();
									   bsdata.setBegin(begin);
									   bsdata.setLimit(BaseCustomerInfoscount);
									   sBaseCustomerInfo.setBsData(bsdata);
									   List<BaseCustomerInfo> listBaseCustomerInfo=sBaseCustomerInfoService.selectAllInfo(sBaseCustomerInfo);
									   for(int j=0;j<listBaseCustomerInfo.size();j++)
									   {
										   BaseCustomerInfo info=listBaseCustomerInfo.get(j);
										   System.out.println(listBaseCustomerInfo.get(j).getCity());
										   info.setSmId(ming);			   				   
										  try
										   {
											  BaseCustomerInfoService.insertSelective(info);					   
										   }
										   catch(Exception e){
											   System.out.println(info.getId()+"@@@@@");
										   }
										   
									   }
									   */  
				/*   int BaseMemberInfoscount=(int)sBaseMemberInfoService.selectAllCount();
				   System.out.println(BaseMemberInfoscount+"总数据量");
				   sBaseMemberInfo sBaseMemberInfo =new sBaseMemberInfo();
				   bsdata.setBegin(begin);
				   bsdata.setLimit(BaseMemberInfoscount);
				   sBaseMemberInfo.setBsData(bsdata);
				   List<BaseMemberInfo> BaseMemberInfolist=sBaseMemberInfoService.selectAllInfo(sBaseMemberInfo);
				   for(int j=0;j<BaseMemberInfolist.size();j++)
				   {
					   BaseMemberInfo info=BaseMemberInfolist.get(j);
					   System.out.println(BaseMemberInfolist.get(j).getMemberName());
					   info.setSmId(ming);			   				   
					  try
					   {
						  BaseMemberInfoService.insertSelective(info);					   
					   }
					   catch(Exception e){
						   System.out.println(info.getMid()+"@@@@@");
					   }
					   
				   }
				   
				   int BaseMemberLogscount=(int)sBaseMemberLogService.selectAllCount();



					   sBaseMemberLog sBaseMemberLogInfo =new sBaseMemberLog();
					   bsdata.setBegin(begin);
					   bsdata.setLimit(BaseMemberLogscount);
					   sBaseMemberLogInfo.setBsData(bsdata);
					   List<BaseMemberLog> BaseMemberLogslist=sBaseMemberLogService.selectAllInfo(sBaseMemberLogInfo);
					   for(int j=0;j<BaseMemberLogslist.size();j++)
					   {
						   BaseMemberLog info=BaseMemberLogslist.get(j);
						   System.out.println(BaseMemberLogslist.get(j).getMemberName());
						   info.setSmId(ming);			   				   
						  try
						   {
							  BaseMemberLogService.insertSelective(info);					   
						   }
						   catch(Exception e){
							   System.out.println(info.getId()+"@@@@@");
						   }
						   
					   }
					   
					   int BaseScalesInfoscount=(int)sBaseScalesInfoService.selectAllCount();


						   sBaseScalesInfo sBaseScalesInfoInfo =new sBaseScalesInfo();
						   bsdata.setBegin(begin);
						   bsdata.setLimit(BaseScalesInfoscount);
						   sBaseScalesInfoInfo.setBsData(bsdata);
						   List<BaseScalesInfo> BaseScalesInfolist=sBaseScalesInfoService.selectAllInfo(sBaseScalesInfoInfo);
						   for(int j=0;j<BaseScalesInfolist.size();j++)
						   {
							   BaseScalesInfo info=BaseScalesInfolist.get(j);
							   System.out.println(BaseScalesInfolist.get(j).getScalesName());
							   info.setSmId(ming);			   				   
							  try
							   {
								  BaseScalesInfoService.insertSelective(info);					   
							   }
							   catch(Exception e){
								   System.out.println(info.getId()+"@@@@@");
							   }
							   
						   }
						   

						   int BaseSupplierInfocount=(int)sBaseSupplierInfoService.selectAllCount();

							   sBaseSupplierInfo sBaseSupplierInfo =new sBaseSupplierInfo();
							   bsdata.setBegin(begin);
							   bsdata.setLimit(BaseSupplierInfocount);
							   sBaseSupplierInfo.setBsData(bsdata);
							   List<BaseSupplierInfo> BaseSupplierInfolist=sBaseSupplierInfoService.selectAllInfo(sBaseSupplierInfo);
							   for(int j=0;j<BaseSupplierInfolist.size();j++)
							   {
								   BaseSupplierInfo info=BaseSupplierInfolist.get(j);
								   System.out.println(BaseSupplierInfolist.get(j).getSupplierName());
								   info.setSmId(ming);			   				   
								  try
								   {
									  BaseSupplierInfoService.insertSelective(info);					   
								   }
								   catch(Exception e){
									   System.out.println(info.getId()+"@@@@@");
								   }
								   
							   }
							   
							   int BaseShopInfoscount=(int)sBaseShopInfoService.selectAllCount();
							   sBaseShopInfo sBaseShopInfoInfo =new sBaseShopInfo();
							   bsdata.setBegin(begin);
							   bsdata.setLimit(BaseShopInfoscount);
							   sBaseShopInfoInfo.setBsData(bsdata);
							   List<BaseShopInfo> BaseShopInfolist=sBaseShopInfoService.selectAllInfo(sBaseShopInfoInfo);
							   for(int j=0;j<BaseShopInfolist.size();j++)
							   {
								   BaseShopInfo info=BaseShopInfolist.get(j);
								   System.out.println(BaseShopInfolist.get(j).getShopName());
								   info.setSmId(ming);									
								   try
								   {
									   BaseShopInfoService.insertSelective(info);					   
								   }
								   catch(Exception e){
									   System.out.println(info.getId()+"@@@@@");
								   }
								   
							   }
							   
							   int SysCompanyInfoscount=(int)sSysCompanyInfoService.selectAllCount();
								   sSysCompanyInfo sSysCompanyInfoInfo =new sSysCompanyInfo();
								   bsdata.setBegin(begin);
								   bsdata.setLimit(SysCompanyInfoscount);
								   sSysCompanyInfoInfo.setBsData(bsdata);
								   List<SysCompanyInfo> SysCompanyInfolist=sSysCompanyInfoService.selectAllInfo(sSysCompanyInfoInfo);
								   for(int j=begin;j<SysCompanyInfolist.size();j++)
								   {
									   SysCompanyInfo info=SysCompanyInfolist.get(j);
									   System.out.println(SysCompanyInfolist.get(j).getNativename());
									   info.setSmId(ming);			   				   
									  try
									   {
										  SysCompanyInfoService.insertSelective(info);					   
									   }
									   catch(Exception e){
										   System.out.println(info.getId()+"@@@@@"); 
									   }
									   
								   }*/
					     
	                  
			     			   
	     return "success";
		}
	   

}
